import React, { Component } from 'react'
import { Form, Input, Button } from 'antd';
// import UploadPicture from '../../components/UploadPicture';
// import MyUpload from "../../components/MyUpload/index"
export default class AvailableChangeForm extends Component {

    onFinish = (values) => {
        console.log(this.props.location.state.item.id);
        values.id = this.props.location.state.item.id
        console.log(values);
        fetch('http://127.0.0.1:8000/Form', {
            method: 'post',
            headers: {
                "Content-type": "application/json"
            },
            body: JSON.stringify(values)
        }).then((response) => {
            return response.json()
        }).then((data) => {
            console.log(data)
        }).catch(function (error) {
            console.log(error)
        })
    };

    onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
    };

    render() {

        const {
            owner,
            title,
            address,
            tel,
            price,
            coverarea,
            property } = this.props.location.state.item

        return (
            <div style={{ marginTop: 40 }}>
                <Form
                    name="basic"
                    labelCol={{
                        span: 3,
                    }}
                    wrapperCol={{
                        span: 7,
                    }}
                    // defaultValues={{
                    //     remember: true,
                    // }}
                    initialValues={{
                        owner,
                        title,
                        address,
                        tel,
                        price,
                        coverarea,
                        property
                    }}
                    onFinish={this.onFinish}
                    onFinishFailed={this.onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item
                        label="房屋拥有者"
                        name="owner"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your owner!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="产权"
                        name="property"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your property!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="标题"
                        name="title"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your title!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="拟流转价格"
                        name="price"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your price!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="流转时间"
                        name="transTime"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your transTime!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="联系人"
                        name="linkMan"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your linkMan!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="联系电话"
                        name="tel"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your tel!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="房屋所在村"
                        name="village"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your village!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="房屋详细地址"
                        name="address"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your address!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>


                    <Form.Item
                        label="产权证号"
                        name="deedNumber"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your deedNumber!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="建成年份"
                        name="buildYear"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your buildYear!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="占地面积"
                        name="coverArea"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your coverArea!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="建筑面积"
                        name="buildArea"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your buildArea!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="建筑结构"
                        name="buildStruct"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your buildStruct!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="房屋层数"
                        name="layNum"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your layNum!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>

                    <Form.Item
                        label="配套"
                        name="support"
                        rules={[
                            {
                                required: true,
                                message: 'Please input your support!',
                            },
                        ]}
                    >
                        <Input />
                    </Form.Item>



                    <Form.Item
                        wrapperCol={{
                            offset: 4,
                            span: 16,
                        }}
                    >
                        <Button type="primary" htmlType="submit">
                            提交
                        </Button>
                    </Form.Item>

                </Form>
                );
            </div >
        )
    }
}
